package com.huhao.consumer.controller;

import com.huhao.consumer.service.CombineService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RequestMapping("/test")
@RestController
public class TestController {
    @Resource
    private CombineService combineService;

    @GetMapping("/combine")
    public Mono<String> combine() {
        long start = System.currentTimeMillis();
        Mono<String> combine = combineService.combine();
        long end = System.currentTimeMillis();
        return combine.map(str -> str + " 耗时：" + (end - start));
    }

    @GetMapping("/sequence")
    public String sequence() {
        long start = System.currentTimeMillis();
        String rtn = combineService.callTestAOld() + combineService.callTestBOld() + combineService.callTestCOld();
        long end = System.currentTimeMillis();
        return rtn + " 耗时：" + (end - start);
    }
}
